﻿package mortal.game.view.shopMall.view
{
    import Message.DB.Tables.*;
    import com.mui.controls.*;
    import com.mui.core.*;
    import extend.language.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.mvc.core.*;

    public class ShopCopyPanel extends ShopCommonPanel
    {
        private var _moneyBg:GImageBitmap;
        private var _currentMoney:GTextFiled;
        private var _getWayTxt:GTextFiled;
        private var _moneyIcon:GBitmap;

        public function ShopCopyPanel()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._moneyBg = UIFactory.gImageBitmap("", 490, 449, this);
            var _loc_1:* = GlobalStyle.textFormatHuang2.right();
            _loc_1.size = 16;
            _loc_1.bold = true;
            this._currentMoney = UIFactory.gTextField("", 570, 451, 90, 30, this, _loc_1);
            this._getWayTxt = UIFactory.gTextField(Language.getString(35564), 705, 445, 65, 50, this, GlobalStyle.textFormatHuang2);
            this._moneyIcon = UIFactory.gBitmap("", 660, 453, this);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._moneyBg.dispose(param1);
            this._moneyBg = null;
            this._currentMoney.dispose(param1);
            this._currentMoney = null;
            this._moneyIcon.dispose(param1);
            this._moneyIcon = null;
            this._getWayTxt.dispose(param1);
            this._getWayTxt = null;
            NetDispatcher.removeCmdListener(ServerCommand.BackPackItemsChange, this.updateMoney);
            super.disposeImpl(param1);
            return;
        }// end function

        override protected function set tshop(param1:TShop) : void
        {
            super.tshop = param1;
            if (_tshop.type == 1)
            {
                NetDispatcher.removeCmdListener(ServerCommand.BackPackItemsChange, this.updateMoney);
                this._getWayTxt.htmlText = Language.getString(35565) + GameDefConfig.instance.getEprictUnitGetWay(_tshop.unit) + "]</font>";
            }
            else if (_tshop.type == 2)
            {
                NetDispatcher.addCmdListener(ServerCommand.BackPackItemsChange, this.updateMoney);
                this._getWayTxt.htmlText = Language.getString(35566);
            }
            this._moneyBg.imgUrl = "ShopMallMoneyBg_" + _tshop.unit + ".png";
            return;
        }// end function

        override public function getItemsByTab(param1:int, param2:int = 0, param3:int = -1) : void
        {
            super.getItemsByTab(param1, param2, param3);
            this.updateMoney();
            return;
        }// end function

        override public function getItemsByTabAndPage(param1:int, param2:int, param3:int = 0, param4:int = -1) : void
        {
            super.getItemsByTabAndPage(param1, param2, param3, param4);
            this.updateMoney();
            return;
        }// end function

        override public function updateMoney(param1:Object = null) : void
        {
            if (_tshop.type == 1)
            {
                this._currentMoney.text = Cache.instance.role.getMoneyByType(_tshop.unit).toString();
            }
            else if (_tshop.type == 2)
            {
                this._currentMoney.text = Cache.instance.pack.backPackCache.getItemCountByItemCode(_tshop.unit).toString();
            }
            this._moneyIcon.bitmapData = GlobalClass.getBitmapData(GameDefConfig.instance.getEPrictUnitImg(_tshop.unit));
            return;
        }// end function

    }
}
